<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content=""> 
    <meta  name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="default" />
	<title>管理平台—登录</title>
	<link href="${base}/assets/biz-logic/css/login.css" rel="stylesheet">
	
</head>
<body>
	<div class="main signin">
	  <div class="center-content special-content">
		<div class="block special-block">
		  
		  <form method="POST" id="loginForm" class="login-form" action="${base}/login">
			<h3 class="title">登录</h3>
			<input type="hidden" name="goto" value="" />
			<input type="text" name="name" placeholder="用户名" value="admin"/>
			<input type="password" name="password" placeholder="密码" value="123456"/>
			<input type="text" name="authCode" placeholder="图形验证码"  
				 maxlength="6" style="width:100px;text-align:center;vertical-align: top;" />
			<img src="${base}/captcha" title="验证码"  
				 style="width:100px;height:36px;margin-left:30px;" id="captcha" />
				&nbsp;&nbsp;<a href="###" onclick="refreshCode()">点这儿刷新验证码</a>
			<div class="line advanced-line">
			  <div class="remember-line">
				<input id="if-remember" type="checkbox" name="remember" value="true"/>
				<label class="tip link" for="if-remember">记住密码</label>
				<a class="abright" href="###">忘记密码</a>
			  </div>
			  <p class="error" id="verify"></p>
			  <p class="error flash-error" id="error">
			  </p>
			</div>

			<div class="align-center line">
			  <button class="btn login" id="loginBtn" type="button">确认登录</button>
			  <!-- <a class="abright register" href="/signup">注册账号</a> -->
			</div>
		  </form>

		  <!-- <div class="vendor-block">
			合作账号登录:
			<a title="使用CSDN账号登录" class="vendor-logo icon-csdn" href="/signup/csdn">CSDN</a>
		  </div> -->
		  <div class="span4">&nbsp;
		  </div>
		</div>
	  </div>
    </div>
    <script type="text/javascript" src="${base}/assets/ace/js/jquery.min.js" ></script>
	<script type="text/javascript">
	$(function(){
		
		document.onkeydown = function(e){
			// 兼容FF和IE和Opera    
	        var theEvent = e || window.event;    
	        var code = theEvent.keyCode || theEvent.which || theEvent.charCode;    
	        if (code == 13) {    
	        	 $('#loginBtn').click();
	            return false;    
	        }    
	        return true;    
		}
		
		$('#loginBtn').click(function(){
			if(checkForm()){
				$.post('${base}/login', $('#loginForm').serialize(), function(r){
					if(r.operationState == "SUCCESS"){
						location.href =  "${base}/main";	
					}else if(r.operationState == "FAIL"){
						$('#verify').show().html(r.data.reason);
						$('input[name="authCode"]').val('');
						refreshCode();
					}
				}, 'json');
			}
		})
	})
	
	function checkForm() {
		var name = $('input[name="name"]').val();
		var pwd = $('input[name="password"]').val();
		var authCode = $('input[name="authCode"]').val();
		if(name.trim() == ''){
			$('#verify').show().html("请输入用户名！");
			$('input[name="name"]').focus();
			return false;
		}
		if(pwd.trim() == ''){
			$('#verify').show().html("请输入登录密码！");
			$('input[name="password"]').focus();
			return false;
		}
		if(authCode == ''){
			$('#verify').show().html("请输入验证码！");
			$('input[name="authCode"]').focus();
			return false;
		}
		$('#verify').hide()
		return true ;
	}
	
	function refreshCode() {
		$('#captcha').attr('src' , "${base}/captcha?v=" + new Date().getTime() );
	}
	</script>
</body>
</html>